Trò chơi đua xe động vật trong UNITY Engine
114.793 lượt xem;
- InterpolationBounce.cs
- Interpolations /
- Bapk /
- Scripts /
- Assets /
- project /
1 using UnityEngine;
2 using System.Collections;
3
4 public class InterpolationBounce : InterpolationBounceOut {
5 private float test;
6
7 public InterpolationBounce(float[] widths, float[] heights) : base(widths, heights)
8 {
9 }
10 public InterpolationBounce(int bounces) : base(bounces) { }
11
12 private float Out(float a)
13 {
14 test = a + widths[0] / 2;
15 if (test < widths[0])
16 return test / (widths[0] / 2) - 1;
17 return base.apply(a);
18 }
19
20 public override float apply(float a)
21 {
22 if (a <= 0.5f)
23 return (1 - Out(1 - a * 2)) / 2;
24 return Out(a * 2 - 1) / 2 + 0.5f;
25 }
26
27 }
2 using System.Collections;
3
4 public class InterpolationBounce : InterpolationBounceOut {
5 private float test;
6
7 public InterpolationBounce(float[] widths, float[] heights) : base(widths, heights)
8 {
9 }
10 public InterpolationBounce(int bounces) : base(bounces) { }
11
12 private float Out(float a)
13 {
14 test = a + widths[0] / 2;
15 if (test < widths[0])
16 return test / (widths[0] / 2) - 1;
17 return base.apply(a);
18 }
19
20 public override float apply(float a)
21 {
22 if (a <= 0.5f)
23 return (1 - Out(1 - a * 2)) / 2;
24 return Out(a * 2 - 1) / 2 + 0.5f;
25 }
26
27 }